package com.chushouya.controller.product.api;

import com.chushouya.common.annotations.AuthSkip;
import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.schema.Response;
import com.chushouya.product.dto.admin.series.SeriesQuery;
import com.chushouya.product.dto.api.series.SeriesApiDTO;
import com.chushouya.product.service.api.ProductSeriesApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = ServiceType.API + "商品系列")
@RestController
@RequestMapping(ServiceType.API + "/series")
public class ProductSeriesApiController {

    @Resource
    private ProductSeriesApiService productSeriesApiService;

    @ApiOperation("获取商品系列")
    @GetMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "categoryId", value = "类目id", required = true),
            @ApiImplicitParam(name = "brandId", value = "品牌id", required = true),
    })
    @AuthSkip
    public Response<List<SeriesApiDTO>> listProductSeries(Long categoryId, Long brandId) {
        SeriesQuery query = new SeriesQuery();
        query.setCategoryId(categoryId);
        query.setBrandId(brandId);
        return Response.success(productSeriesApiService.listProductSeries(query));
    }
}
